
import axios from '../handleService'
export default {
  createWorkflow: data => axios.post('/api/workflow', data),
  // createWorkflowNode: (workflow_id, data) => axios.post(`/api/workflow/${workflow_id}/node`, data),
  // getNodeList: (workflow_id, commit_id) => axios.get(`/api/workflow/${workflow_id}${commit_id ? '?commit_id=' + commit_id : ''}`),
  getWorkflowPreview: (workflow_id, commit_id) => axios.get(`/api/workflow/${workflow_id}/script${commit_id ? '?commit_id=' + commit_id : ''}`),
  saveAsNotebook: (workflow_id, data) => axios.post(`/api/workflow/${workflow_id}/notebook`, data),
  // checkMlsql: data => axios.post('/api/sql/validation', data),
  // getNodeInfo: (workflow_id, node_id) => axios.get(`/api/workflow/${workflow_id}/node/${node_id}`),
  // updateFlowNode: (workflow_id, node_id, data) => axios.put(`/api/workflow/${workflow_id}/node/${node_id}`, data),
  // getExsitingTable: workflow_id => axios.get(`/api/workflow/${workflow_id}/output`),
  // getExsitingModel: id => axios.get(`/api/workflow${id ? ('/' + id) : ''}/model`),
  // updateNodePosition: (workflow_id, node_id, data) => axios.put(`/api/workflow/${workflow_id}/node/${node_id}/position`, data),
  // deleteWorkflowNode: (workflow_id, node_id) => axios.delete(`/api/workflow/${workflow_id}/node/${node_id}`),
  getLoadParams: ({ node_type, node_name, param_name }) => axios.get(`/api/settings/node/param?node_type=${node_type}&node_name=${node_name}&param_name=${param_name}`),
  // getETList: () => axios.get('/api/et'),
  getETParams: et_id => axios.get(`/api/et/${et_id}/params`),
  getETDependency: data => axios.post('/api/et/dependency', data),

  // 工作流输出 
  getExsitingTable: workflow_id => axios.get(`/api/workflow/${workflow_id}/output`),
  // 获取工作流详情 
  getNodeList: (workflow_id) => axios.get(`/api/workflow/${workflow_id}`),
  // 运行工作流
  runWorkflow: (workflow_id, data) => axios.post(`/api/workflow/${workflow_id}/execution`, data),

  // 新增节点  
  createWorkflowNode: data => axios.post(`/api/workflow/node/`, data),
  // 节点移动 
  updateNodePosition: (workflow_id, node_id, data) => axios.put(`/api/workflow/node/${node_id}/position`, data),
  // 节点详情 
  getNodeInfo: (workflow_id, node_id) => axios.get(`/api/workflow/node/${node_id}`),
  // 节点更新
  updateFlowNode: (node_id, data) => axios.put(`/api/workflow/node/${node_id}`, data),
  // 删除节点 
  deleteWorkflowNode: (workflow_id, node_id) => axios.delete(`/api/workflow/node/${node_id}`),
  // 模型列表  
  getExsitingModel: id => axios.get(`/api/workflow/model/?workflowId=${id}`),
  // 获取列表 
  getETList: () => axios.get('/api/et/list'),
  // 校验 SQL 
  checkMlsql: data => axios.post('/api/workflow/check/sql', data),
}
